# ---------------------------------------------------------
cmake_minimum_required(VERSION 2.8)

PROJECT(nsg-sandbox)

find_package(OpenGL REQUIRED)

# Include necessary submodules
set(CMAKE_MODULE_PATH
  "${CMAKE_CURRENT_SOURCE_DIR}/CMake"
  "${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils"
)

include (cmake/Utils/nsUtils.cmake)

if(WIN32)

	if(MSVC AND NOT "${MSVC_VERSION}" LESS 1400)
		add_definitions( "/MP" )
	endif()

	if (MSVC)
		add_definitions( -D_CRT_SECURE_NO_WARNINGS )
		add_definitions( -D_CRT_SECURE_NO_DEPRECATE )
		add_definitions( -DNOMINMAX)

		#We statically link to reduce dependancies
		FOREACH(flag_var    CMAKE_CXX_FLAGS
							CMAKE_CXX_FLAGS_DEBUG
							CMAKE_CXX_FLAGS_RELEASE
							CMAKE_CXX_FLAGS_MINSIZEREL
							CMAKE_CXX_FLAGS_RELWITHDEBINFO
							CMAKE_C_FLAGS_DEBUG
							CMAKE_C_FLAGS_RELEASE
							CMAKE_C_FLAGS_MINSIZEREL
							CMAKE_C_FLAGS_RELWITHDEBINFO
							)
			IF(${flag_var} MATCHES "/MD")
				STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
			ENDIF(${flag_var} MATCHES "/MD")
			IF(${flag_var} MATCHES "/MDd")
				STRING(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
			ENDIF(${flag_var} MATCHES "/MDd")
		ENDFOREACH(flag_var)

	ENDIF(MSVC)

endif(WIN32)

if(CMAKE_COMPILER_IS_GNUCXX)
	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
endif()

###########################
# glfw
###########################
set(GLFW_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glfw/include)
mark_as_disable_and_internal(USE_MSVC_RUNTIME_LIBRARY_DLL)
mark_as_disable_and_internal(GLFW_BUILD_EXAMPLES)
mark_as_disable_and_internal(GLFW_BUILD_TESTS)
mark_as_disable_and_internal(GLFW_INSTALL)
add_subdirectory(glfw)

###########################
# test
###########################
add_subdirectory(test)

